#ifndef VIDEODOWNLOADER_H
#define VIDEODOWNLOADER_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QTimer>
#include <QFile>
#include <QJsonArray>
#include <QJsonObject>

class VideoDownloader : public QObject
{
    Q_OBJECT

public:
    explicit VideoDownloader(QObject *parent = nullptr);
    ~VideoDownloader();
    void fetchVideos();
    void downloadVideo(const QString &url, const QString &filename);

    void start();

private slots:
    void onTimerTimeout();
    void onGetVideosFinished(QNetworkReply *reply);
    void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
    void onDownloadFinished();

private:

    QNetworkAccessManager *networkManager;
    QTimer *timer;
    QString serverUrl;
    QString downloadPath;
    QNetworkReply *currentDownload;
};

#endif // VIDEODOWNLOADER_H
